%% test baseline for each subject

for d = 1:3:length(ALLEEG)
    EEG1 = ALLEEG( d );
    EEG2 = ALLEEG( d+1 );
    EEG1.data = eeg_getdatact(EEG1, 'verbose', 'off');
    EEG2.data = eeg_getdatact(EEG2, 'verbose', 'off');
    
    range1 = [-2000 -1010];
    EEG1 = pop_rmbase(EEG1, range1);
    EEG2 = pop_rmbase(EEG2, range1);
    range2 = [-1000 -10];

    [tmp t1] = min(abs(EEG1.times-range2(1)));
    [tmp t2] = min(abs(EEG1.times-range2(2)));
    ERP1 = squeeze(mean(EEG1.data(:,t1:t2,:),2));
    ERP2 = squeeze(mean(EEG2.data(:,t1:t2,:),2));
    %ERPmean2(:,1:43)  = ERPmean1(:,1:43)+2;
    %ERPmean2(:,44:94) = ERPmean1(:,44:94)-2;

    [t df p] = statcond({ ERP1 ERP2}, 'mode', 'bootstrap', 'naccu', 4000, 'verbose', 'off');
    p = fdr(p);
    fprintf('%s, %s, p-values: %2.4f\n', ALLEEG(d).subject, STUDY.datasetinfo(d).group, min(p));
end;
